package com.forever7776.life.core.mapper.stat;

import com.forever7776.life.core.entity.stat.StatBlog;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 博客统计表 Mapper 接口
 * </p>
 *
 * @author kz
 * @since 2018-04-11
 */
public interface StatBlogMapper extends BaseMapper<StatBlog> {

    /**
     * 给该博客阅读数量+1
     *
     * @param blogId
     * @return
     */
    @Update("update stat_blog set read_count = read_count+1 where blog_id=#{blogId}")
    int addReadStatCount(@Param("blogId") Integer blogId);

    /**
     * 给该博客收藏数量+1
     *
     * @param blogId
     * @return
     */
    @Update("update stat_blog set collect_count = collect_count+1 where blog_id=#{blogId}")
    int addCollectStatCount(@Param("blogId") Integer blogId);

    /**
     * 给该博客点赞数量+1
     *
     * @param blogId
     * @return
     */
    @Update("update stat_blog set praise_count = praise_count+1 where blog_id=#{blogId}")
    int addPraiseStatCount(@Param("blogId") Integer blogId);


    /**
     * 给该博客阅读数量-1
     *
     * @param blogId
     * @return
     */
    @Update("update stat_blog set read_count = read_count-1 where blog_id=#{blogId}")
    int cutReadStatCount(@Param("blogId") Integer blogId);

    /**
     * 给该博客收藏数量-1
     *
     * @param blogId
     * @return
     */
    @Update("update stat_blog set collect_count = collect_count-1 where blog_id=#{blogId}")
    int cutCollectStatCount(@Param("blogId") Integer blogId);

    /**
     * 给该博客点赞数量-1
     *
     * @param blogId
     * @return
     */
    @Update("update stat_blog set praise_count = praise_count-1 where blog_id=#{blogId}")
    int cutPraiseStatCount(@Param("blogId") Integer blogId);

}
